package com.xopencode.spring.config;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.PayloadApplicationEvent;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;

/**
 * @Auther: Mcb
 * @Date: 2022/3/1 23:18
 * @Description:
 */
@Configuration
@ComponentScan(value = "com.xopencode.spring")
public class SpringListenerConfig {


    @EventListener
    public void lister(ApplicationEvent event){
         if (event instanceof PayloadApplicationEvent){
             System.out.println("时间监听");
             PayloadApplicationEvent payloadApplicationEvent = (PayloadApplicationEvent) event;
             System.out.println("getPayload---"+payloadApplicationEvent.getPayload());
             System.out.println("getResolvableType---"+payloadApplicationEvent.getResolvableType());
         }
    }
}
